<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1 user-scalable=0">
<link rel="stylesheet" href="<%=basePath%>assets/css/page.css">
<link rel="stylesheet"
	href="<%=basePath%>assets/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>assets/css/globle.css" />
<meta name="viewport" content="width=device-width,initial-scale=1 user-scalable=0">
<title>发布</title>
<link rel="stylesheet" href="<%=basePath%>assets/css/public.css">
<link rel="stylesheet" href="<%=basePath%>assets/css/idangerous.swiper.css">
<script src="<%=basePath%>assets/js/jquery-1.8.3.min.js"></script>
<script src="<%=basePath%>assets/js/fontSize.js"></script>
<link rel="stylesheet" href="<%=basePath%>/assets/imgTools/helmet.css">
<script src="<%=basePath%>/assets/layer/mobile/layer.js"></script>
<script src="<%=path%>/assets2/js/jquery.form.js"></script>

<style>
html {
	width: 100%;
	height: 100%
}

body {
	padding-top: 1.6rem;
}

header {
	background: #f1f1f1
}

.title {
	font-size: 0.4rem;
	line-height: 0.8rem;
	text-align: center;
	padding: 0 0.6rem
}

header a {
	float: left;
	width: 0.3rem;
	height: 0.8rem;
	font-size: 0.3rem;
	line-height: 0.8rem;
	padding: 0 0.3rem
}

.biaotitianxie {
	height: 0.8rem;
	line-height: 0.6rem;
	width: 100%;
	border-bottom: 1px solid #f1f1f1;
	font-size: 0.24rem;
	display: block;
}

.neirongtianxie {
	height: 1.6rem;
	width: 100%;
	border: none;
	font-size: 0.24rem;
	line-height: 0.4rem;
	padding-top: 10px;
	display: block;
}

.upload-btn {
    padding: 14px 0px;
    color: #fff;
    margin: 0; 
    width: 100%;
    text-align: center;
}




.upload-pick{
	position: relative;
}

</style>
</head>
<body>
	<input id="basePath" type="hidden" value="<%=basePath%>">
	<div class="header">
		<!-- 返回按钮 -->
		<a class=returnInfo onclick="returnDescend()"><i class="fa fa-angle-left"></i></a> 发布
	</div>
	<form role="form" id="fm" action="<%=path%>/app/addComplains" method="post" enctype="multipart/form-data" >
		<div class="content" style="margin-top: -10%;">
			<input name="respondTargerId" type="hidden" value="${respondTargerId}">
			<input name="goalId" type="hidden" value="${goalId}">
			<input name="urlState" type="hidden" value="${urlState}">
			<input id="goodsName" type="text" placeholder="标题  投诉建议的标题"
				class="biaotitianxie" value="${name}" disabled="disabled">
			<textarea id="complainsContent" placeholder="描述一下您的投诉或者建议"
				class="neirongtianxie" maxlength="500" name="complainsContent"></textarea>
			<div>
				<ul class="img-list upload-ul clearfix">
					<li class="upload-pick">
						<input type="file" name="file" class="webuploader-element-invisible" id="choose" accept="image/*"  style="height: 115px;height: 100px;" >
						<img alt="" src="" id="headImg" style="height: 90px;position: fixed;top: 206px;right: 13px;">
					</li>
				</ul>
			</div>
			<p>
				<a id="sellGoods" class="upload-btn" href="javascript:;"
					style="background-color: #FF3F25;" onclick="release()" id="subBtn">确定发布</a>
			</p>
		</div>
   </form>
</body>
<script>
//加载图片
$('#choose').on('change',function(){
	   var fileName=this.value;
		while (fileName.indexOf("\\") != -1)
		{
	    fileName = fileName.slice(fileName.indexOf("\\") + 1);
		}
	    var ext = fileName.slice(fileName.indexOf(".")).toLowerCase();
	    if(ext.indexOf("png") == -1 && ext.indexOf("jpg") == -1)
	    {
	    	layer.open({
		    content: '商品图片格式仅支持PNG、JPG~'
		    ,skin: 'msg'
		    ,time: 2 //2秒后自动关闭
		  });
	    	return false;
	    }
		var objUrl = getObjectURL(this.files[0]);
		$("#headImg").attr("src",objUrl);
});
       //投诉建议
	   function release(){
    	    var objUrl = $("#headImg").attr("src"); 
    	    var complainsContent = $("#complainsContent").val();
    	    if(complainsContent==null||complainsContent==''){
    	    	layer.open({
	      			    content: '请描述您的投诉建议~'
	      			    ,skin: 'msg'
	      			    ,time: 2 //2秒后自动关闭
	      			  });
    	    	return false;
			}else if(objUrl==null||objUrl==''){
			  layer.open({
				    content: '请选择您需要投诉建议的图片~'
				    ,skin: 'msg'
				    ,time: 3 //2秒后自动关闭
				  });
			  return false;
			}else{
				 $('#fm').ajaxSubmit({
						beforeSubmit:function(){
							$("#subBtn").unbind("click");
						},success:function(data) { 
						if(data.num==1){
							 layer.open({
		        			    content: '投诉成功~'
		        			    ,skin: 'msg'
		        			    ,time: 2 //2秒后自动关闭
		        			  });
							 if(data.urlState==0){
								 window.location.href="<%=basePath%>app/goodsList?merchantId="+data.goalId;
							 }else {
								 window.location.href="<%=basePath%>app/getUserOrderList";
							 }
						}else{
							layer.open({
			 	      			    content: '投诉失败~'
			 	      			    ,skin: 'msg'
			 	      			    ,time: 2 //2秒后自动关闭
			 	      			  });	
							}
						}
					});
			}
    };
//返回上一层
function returnDescend() {
	window.location.href=$("#basePath").val()+"app/toPersonCenter";
};
//建立一個可存取到該file的url  
function getObjectURL(file) {
	var url = null;
	// 下面函数执行的效果是一样的，只是需要针对不同的浏览器执行不同的 js 函数而已  
	if (window.createObjectURL != undefined) { // basic  
		url = window.createObjectURL(file);
	} else if (window.URL != undefined) { // mozilla(firefox)  
		url = window.URL.createObjectURL(file);
	} else if (window.webkitURL != undefined) { // webkit or chrome  
		url = window.webkitURL.createObjectURL(file);
	}
	return url;
}
</script>
</html>